package contest.sweek204;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/8/30 10:27
 */
public class Solution1 {

    public boolean containsPattern(int[] arr, int m, int k) {
        int l = m * k;
        int n = arr.length;
        for(int i = 0; i <= n - l; i++) {
            int count = k;
            int[] temp = new int[m];
            for(int j = 0; j < m; j++) {
                temp[j] = arr[i + j];
            }
            count--;
            for(int r = i + m; r + m <= n; r += m) {
                boolean f = true;
                for(int c = 0; c < m; c++) {
                    if(arr[r + c] != temp[c])  {
                        f = false;
                        break;
                    }
                }
                if(!f) break;
                count--;
                if(count == 0) return true;
            }
        }
        return false;
    }
}
